walkthrough.Another useful function is ReadAtLeast() :
func ReadAtLeast(r Reader, buf []byte, min int) (n int, err error)
This function reads the additional data into the buffer and, if available, always returns the minimum number of bytes. I do not see the need for this feature, but if you need to minimize the Read() call and you are willing to buffer the additional data, I can see that it is useful.
concatenating streams
Many times, you will encounter instances where multiple read operations
the hard drive when it is not needed. Lucene itself is an excellent indexing engine that provides efficient indexing and retrieval mechanisms. The purpose of the text is to introduce how to read the required information from the data of the already built index, such as using the Lucene API. As for how Lucene is used, I will introduce it in subsequent articles.Let's take a step at a look. Here the construction has been implemented to build a good index, stored in the index directory. Well, to re
);Hits hits = Searcher.search (query);4. Distribution Searchwe can use Multireader or Multisearcher Search multiple Index libraries. Multireader reader = new Multireader (new indexreader[] {Indexreader.open (@ "C:\index"), Indexreader.open (@ "\\server\ Index ")});Indexsearcher searcher = new Indexsearcher (reader);Hits hits = Searcher.search (query);OrIndexsearc
= searcher. Search (query );
7. distributed search
We can use MultiReader or MultiSearcher to search for multiple index libraries.MultiReader reader = new MultiReader (new IndexReader [] {IndexReader. Open (@ "c: \ index"), IndexReader. Open (@ "\ server \ index ")});
IndexSearcher searcher = new IndexSearcher (reader );
Hits hits = searcher. Search (query );
OrIndexSearcher searcher1 = new IndexSearcher (
This is a creation in
Article, where the information may have evolved or changed.
Today we continue to talk about the Golang standard library IO Library, we put the IO library is finished today, so we say no more, give us the explanation and code
[1]type Reader[PHP]Type Reader Interface {Read (P []byte) (n int, err error)}[/php](1) func LimitReader(r Reader, n int64) Reader , we said before that the structure of reader, in fact, this is the reader of a package, limit the number of byte
in a new inverted index structure. Lucene's transactional, so that Lucene index is not real-time, if you want Lucene real-time, you must add a new document after IndexWriter need commit, in the search Indexreader need to reopen, However, when the index is on the hard disk, especially when the index is very large, the commit operation of IndexWriter and the open operation of Indexreader are very slow, and the need of real-time is not reached at all.In fact, the general application, if you can al
Booleanquery with filter criteria query = new Booleanquery (); query. ADD (Query1, BooleanClause.Occur.MUST); query. ADD (Query2, BooleanClause.Occur.MUST); Indexsearcher searcher = new Indexsearcher (reader); Hits Hits = searcher. Search (query);8. Distribution SearchWe can search multiple index libraries using Multireader or Multisearcher.Multireader reader = new Multireader (new indexreader[] {Indexread
-15"));Filter filter2 = new Rangefilter (FieldNumber, numbertools.longtostring (11L), numbertools.longtostring (13L), True, True );Query query = queryparser.parse ("name*", FieldName, analyzer);query = new Filteredquery (query, filter);query = new Filteredquery (query, filter2);Indexsearcher searcher = new Indexsearcher (reader);Hits Hits = searcher. Search (query);7. Distribution SearchWe can search multiple index libraries using Multireader or Multi
the same as general searches.
Lucene. Net simultaneously searches for Multiple indexes
When creating an index, you can create multiple indexes according to the category, and search for all indexes at the same time. This function is implemented by multisearcher.
Java mode:
Indexsearcher [] searchers = new indexsearcher [] {New indexsearcher (dir1), new indexsearcher (dir2 )};
Multisearcher msearcher = new multisearcher (searchers );
Query of multiple index files in Lucene. Net: . Net mod
WiduuFmt. PRINTLN ("read number", N)//read Number 10}
Type Reader
Copy Code code as follows:
Type Reader Interface {
Read (P []byte) (n int, err error)
}
(1) Func Limitreader (R reader, n Int64) reader, we have previously said reader this structure, in fact, this is a reader of the package, limited it read bytes, in fact, he achieved is IO. limitedreader{} This structure
Copy Code code as follows:
Import (
"FMT"
"IO"
"OS"
"Refle
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.